// add by yanyj 20180704 start
// 地图的方法集

function createPolygonFeature(coordinatesArray, name) {
    let feature = new ol.Feature({
        geometry: new ol.geom.MultiPolygon([coordinatesArray])
    });

    let color = createColorArray();
    feature.setStyle( new ol.style.Style({
        stroke: new ol.style.Stroke({width:2,color: color.concat(1)}),
        fill: new ol.style.Fill({color: color.concat(0.2)}),
        text: new ol.style.Text({
            text: name,
            font: '20px sans-serif',
            fill: new ol.style.Fill({color: [254,254,254,1]}),
        })
    }));

    return [feature];
}


// 生成画图用的draw
function createDraw(type, source, style) {
    return new ol.interaction.Draw({
        source: source,
        type: type,
        style: style || new ol.style.Style({
            fill: new ol.style.Fill({
                color: 'rgba(255, 255, 255, 0.2)'
            }),
            stroke: new ol.style.Stroke({
                color: 'rgba(0, 0, 0, 0.5)',
                lineDash: [10, 10],
                width: 2
            }),
            image: new ol.style.Circle({
                radius: 5,
                stroke: new ol.style.Stroke({
                    color: 'rgba(0, 0, 0, 0.7)'
                }),
                fill: new ol.style.Fill({
                    color: 'rgba(255, 255, 255, 0.2)'
                })
            })
        })
    });
}

// add by yanyj 20180704 end